package com.generator.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.generator.entity.Template;
import com.generator.dao.TemplateMapper;
    import com.generator.service.TemplateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.generator.shop.entity.Shop;
import com.generator.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
* <p>
    * 代码生成器模板 服务实现类
    * </p>
*
* @author miao
* @since 2024-01-19
*/
@Service
    public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> implements TemplateService {

    @Autowired
    private TemplateMapper dao;

    public QueryWrapper<Template> getQueryWrapper(Map<String, Object> params) {
        QueryWrapper<Template> templateQueryWrapper = new QueryWrapper<>();
        return templateQueryWrapper;
    }

    @Override
    public PageData<Template> Page(Map<String, Object> params) {
        QueryWrapper<Template> queryWrapper = getQueryWrapper(params);
        Page<Template> page = new Page<>(0, 10);
        Page<Template> pageInfo = super.page(page, queryWrapper);
        return new PageData<>(pageInfo.getRecords(), pageInfo.getTotal());
    }

    @Override
    public int add(Template entity) {
        return dao.insert(entity);
    }

    @Override
    public int delete(Long id) {
        return dao.deleteById(id);
    }

    @Override
    public int update(Template entity) {
        return dao.updateById(entity);
    }
}
